Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples for search #11338

Merged
merged 5 commits into from
May 11, 2020
Merged

Samples for search #11338

merged 5 commits into from
May 11, 2020

Conversation

rakshith91
Copy link
Contributor

No description provided.

@rakshith91 rakshith91 requested review from lmazuel and mayurid as code owners May 8, 2020 17:15
@@ -39,21 +39,21 @@ def __init__(self, endpoint, credential, **kwargs):
endpoint=endpoint, sdk_moniker=SDK_MONIKER, **kwargs
) # type: _SearchServiceClient

def __enter__(self):
async def __aenter__(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

messed up aio in indexer :(

@bryevdv
Copy link
Contributor

bryevdv commented May 8, 2020

@rakshith91 can you update the samples readme as well:

https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/search/azure-search-documents/samples

@bryevdv
Copy link
Contributor

bryevdv commented May 11, 2020

@heaths @rakshith91 can we get this merged today to support the UX study, and make any necessary issues for other things to follow-up on?

heaths
heaths previously approved these changes May 11, 2020
Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm signing off so you can make headway for the UX study, but the class names and related method names aren't correct based on what we decided previously. I would be better if these were correct for the UX study so we can get accurate feedback (e.g. maybe they are indeed too long, which is good feedback for the archboard).

index_name = "hotels"
fields = [
SimpleField(name="hotelId", type=edm.String, key=True),
SimpleField(name="baseRate", type=edm.Double)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for what looks like a more complete (enough) example, maybe add a hotelName that is a SearchableField with a few bells and whistles. As a consumer, this index would give me nothing useful (I'd see a base rate, but for whom?).

SimpleField(name="baseRate", type=edm.Double)
]
index = Index(name=index_name, fields=fields)
ind_client = service_client.get_indexes_client()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, the method name should comply with the guidelines, i.e. that the model name is part of not only the client name ({Model}Client), but the method is get_{Model}Client (granted, in snake case idiomatic of python). Might consider doing before the UX study so, if people say "that's too long", we can take that back to archboard.

index = Index(name=index_name, fields=fields)
ind_client = service_client.get_indexes_client()
async with ind_client:
index = await ind_client.create_index(index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods - now on sub-clients - should not repeat the model. I.e. just create. Same as below for other sub-clients.

data_source = await ds_client.create_datasource(ds)

# create an indexer
indexer = Indexer(name="async-sample-indexer", data_source_name="async-indexer-datasource", target_index_name="hotels")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchIndexer. See #10860.

# [START create_indexer_async]
# create a datasource
ds_client = service_client.get_datasources_client()
credentials = DataSourceCredentials(connection_string=connection_string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This connection string should just go onto the SearchIndexerDataSource. See #10860.

# create a datasource
ds_client = service_client.get_datasources_client()
credentials = DataSourceCredentials(connection_string=connection_string)
container = DataContainer(name='searchcontainer')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchIndexerDataContainer. See #10860.

ds_client = service_client.get_datasources_client()
credentials = DataSourceCredentials(connection_string=connection_string)
container = DataContainer(name='searchcontainer')
ds = DataSource(name="async-indexer-datasource", type="azureblob", credentials=credentials, container=container)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchIndexerDataSource. See #10860.

@@ -0,0 +1,187 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you already have samples using medical data? Seems most others have been using the hotels sample. As long as you're consistent, though. If this is the first of new samples, you might consider a consistent model (i.e. hotels) for similarity across languages' samples.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having skimmed the contents as well, I'm a little worried the topic of conversation might be triggering to people who have been impacted by this tragedy. Hotels seem pretty safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it to use hotel data - agree with patient data being sensitive - yes i already had the data for a different project i've been working on

SimpleField(name="estimatedonsetdate", type=edm.String),
SimpleField(name="gender", type=edm.String, filterable=True),
SimpleField(name="nationality", type=edm.String),
SimpleField(name="notes", type=edm.String),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all SimpleFields? At leaset for this one, using a SearchableField not only provides some diversity but would also set a better recommendation for such fields that people might want to use analyzers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)

# pass in the name, fields and cors options and create the index
index = Index(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchIndex. See #10860.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think it is best to merge this PR, then do the updates in the other PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10860 should be done in a different PR

@bryevdv
Copy link
Contributor

bryevdv commented May 11, 2020

Regarding #10860 I had imagined merging this PR first, and then continuing any updates in #10860 so we can't make those changes in this PR since the renames are not in place yet.

@rakshith91
Copy link
Contributor Author

will work on renaming in a different pr

@rakshith91 rakshith91 merged commit dfbc8ca into Azure:master May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants